package com.ganlinux.pangoo.controller.restful.footmark;


import com.alibaba.fastjson.JSON;
import com.ganlinux.pangoo.controller.restful.base.BaseController;
import com.ganlinux.pangoo.dao.model.User;
import com.ganlinux.pangoo.dao.model.UserFootmarkList;
import com.ganlinux.pangoo.entity.request.ReqFootPrintDelete;
import com.ganlinux.pangoo.entity.request.ReqLogin;
import com.ganlinux.pangoo.entity.response.RspFootPrintDeleteData;
import com.ganlinux.pangoo.entity.response.base.RspBase;
import com.ganlinux.pangoo.tools.StringUtil;
import com.jfinal.aop.Before;
import com.jfinal.kit.HttpKit;

/**
 * BlogController
 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
 */
@Before(FootMarkDeleteInterceptor.class)
public class FootMarkDeleteController extends BaseController {
	public void save() {
		super.save();
		RspBase rspLogin = new RspBase();
		String pin = null;
		int footPrintId = -1;

		String jsonString= HttpKit.readData(getRequest());
		ReqFootPrintDelete reqFootPrintDelete = JSON.parseObject(jsonString, ReqFootPrintDelete.class);
		reqFootPrintDelete.setReqHeader(getHeaderFromRequest(getRequest()));
		pin = reqFootPrintDelete.getReqHeader().getPin();
		footPrintId = reqFootPrintDelete.getFootPrintId();

		RspFootPrintDeleteData rspFootPrintDeleteData = UserFootmarkList.dao.deleteFootPrint(pin,footPrintId);
		if (rspFootPrintDeleteData == null) {
			rspLogin.setStatus(1);
			rspLogin.setMessage("失败");
		}else{
			rspLogin.setStatus(0);
			rspLogin.setData(rspFootPrintDeleteData);
			rspLogin.setMessage("成功");
		}
		renderText(JSON.toJSONString(rspLogin));
	}

}


